//
//  NavigationView.m
//  YLP
//
//  Created by EPWK on 14-12-26.
//
//

#import "NavigationView.h"

@implementation NavigationView
-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = CGRectMake(0, 0, ScreenWith, NavigationH);
        self.backgroundColor = NavigationViewBackGroundColor;
        
        self.leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.leftButton.frame = CGRectMake(0, NavigationH - 40, 60, 35);
        self.leftButton.backgroundColor = [UIColor clearColor];
        [self.leftButton addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        self.leftButton.hidden = YES;
        [self.leftButton setTitleColor:[UIColor colorWithRed:245/255.f green:57/255.f blue:129/255.f alpha:1.0] forState:UIControlStateNormal];
        [self addSubview:self.leftButton];
        
        self.rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.rightButton.frame = CGRectMake(ScreenWith - 60, NavigationH - 40, 60, 35);
        self.rightButton.backgroundColor = [UIColor clearColor];
        self.rightButton.hidden = YES;
        [self.rightButton addTarget:self action:@selector(rightBtnClick:)
                   forControlEvents:UIControlEventTouchUpInside];
        [self.rightButton setTitleColor:[UIColor colorWithRed:245/255.f green:57/255.f blue:129/255.f alpha:1.0] forState:UIControlStateNormal];
        [self addSubview:self.rightButton];
        
        self.titleNameLab = [[UILabel alloc] init];
        self.titleNameLab.frame = CGRectMake(ScreenWith/2 - 60, NavigationH - 35, 120, 25);
        self.titleNameLab.textAlignment = NSTextAlignmentCenter;
        self.titleNameLab.backgroundColor = [UIColor clearColor];
        self.titleNameLab.font = [UIFont systemFontOfSize:18.0];
        self.titleNameLab.textColor = [UIColor colorWithRed:60/255.f green:60/255.f blue:60/255.f alpha:1.0];
        [self addSubview:self.titleNameLab];
        
        self.lineView = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationH - 0.5, ScreenWith, 0.5)];
        self.lineView.backgroundColor = [UIColor colorWithRed:204/255.f green:204/255.f blue:204/255.f alpha:1.0];
        [self addSubview:self.lineView];
    }
    return self;
}

-(void)leftBtnClick:(id)sender
{
    [self.delegate leftBtnAction:sender];
}
-(void)rightBtnClick:(id)sender
{
    [self.delegate rightBtnAction:sender];
}

@end
